﻿@{
    ViewBag.Title = "ReviewType";
    Layout = "~/Views/Shared/_BasicLayout.cshtml";
}
<script type="text/javascript">
    $(function () {
        var height = $("#divTotal").height();
        var master = $("#master").height();
        var content = parseFloat(height) - parseFloat(master) - 30;
        $("#tbList").css("height", content);
    });
</script>
<script type="text/javascript">
    $(function () {
        $("#tbList").datagrid({
            url: '/Review/GetReviewTypeList',
            loadMsg: '数据加载中请稍后……',
            pagination: true,
            rownumbers: true,
            idField: "ID",
            singleSelect: true,
            pageSize: 20,
            pageList: [20, 50, 100],
            queryParams: com.serializeSearchArray("form1"),
            striped: true,
            columns: [[{ field: 'ck', checkbox: true, width: 30 },
             { field: 'ID', title: 'ID ', align: "center", width: 30 },
             { field: 'DocCode', title: '审批编号 ', align: "center", width: 80 },
             {
                 field: 'DocName', title: '审批类型 ', align: "center", width: 100, editor: {
                     type: "validatebox",
                     options: {
                         required: true
                     }
                 }
             },
             {
                 field: 'ModName', title: '模块名称 ', align: "center", width: 100, editor: {
                     type: "combobox",
                     options: {
                         data: StaticCombo.ModName,
                         valueField: 'value',
                         textField: 'text',
                         required: true,
                         onChange: function (newValue, oldValue) {
                             //   var row = $("#tbList").datagrid('getSelected');
                             if (editRow != undefined) {
                                 var rindex = editRow;
                                 //  alert(rindex);
                                 var ed = $("#tbList").datagrid('getEditor', {
                                     index: rindex,
                                     field: 'PermissionId'
                                 });
                                 var url = '/Permission/GetSubPermByModelName&modelName=' + com.getArrayText(StaticCombo.ModName, newValue);
                                 //  console.log(ed);
                                 $(ed.target).combobox('reload', url);
                             }
                         }
                     }
                 }, formatter: function (value, row, index) {
                     return com.getArrayText(StaticCombo.ModName, value);
                 }
             },
             //{
             //    field: 'RevFolw', title: '流转方式 ', align: "center", width: 80,
             //    formatter: function (value, row, index) {
             //        return com.getArrayText(StaticCombo.flowType, value);
             //    }, editor: {
             //        type: "combobox",
             //        options: {
             //            data: StaticCombo.flowType,
             //            valueField: 'value',
             //            textField: 'text',
             //            required: true
             //        }
             //    }
             //},

                        {
                            field: 'PermissionId', title: '对应权限 ', align: "center", width: 120,
                            formatter: function (value, row, index) {
                                return row.Name;
                            }, editor: {
                                type: "combobox",
                                options: {
                                    url: "/Permission/GetSubPerm",
                                    valueField: 'value',
                                    textField: 'text',
                                    required: true,
                                    panelWidth: 'auto',
                                }
                            }
                        },

             {
                 field: 'TotalUrl', title: '页面地址 ', align: "center", width: 150, editor: {
                     type: "validatebox",
                     options: {

                         required: true
                     }
                 }
             },
             {
                 field: 'OrderName', title: '单据名称 ', align: "center", width: 100, name: "ordername", editor: {
                     type: "validatebox",
                     options: {
                         required: true
                     }
                 }
             },
             {
                 field: 'RevTable', title: '单据总表 ', align: "center", width: 120, editor: {
                     type: "validatebox",
                     options: {
                         required: true
                     }
                 }
             },
             {
                 field: 'Class', title: '方法类名 ', align: "center", width: 100, editor: {
                     type: "validatebox",
                     options: {

                     }
                 }
             },
                {
                    field: 'BegionMethod', title: '开始方法 ', align: "center", width: 100, editor: {
                        type: "validatebox",
                        options: {

                        }
                    }
                },
                   {
                       field: 'SuccessMethod', title: '成功方法 ', align: "center", width: 100, editor: {
                           type: "validatebox",
                           options: {

                           }
                       }
                   },
                         {
                             field: 'RejectMethod', title: '驳回方法 ', align: "center", width: 100, editor: {
                                 type: "validatebox",
                                 options: {


                                 }
                             }
                         },
                                // {
                                //     field: 'CanBackAudit', title: '是否反审 ', align: "center", width: 100, formatter: function (value, row, index) {
                                //         return com.getArrayText(StaticCombo.CanBackAudit, value);
                                //     }, editor: {
                                //         type: "combobox",
                                //         options: {
                                //             data: StaticCombo.CanBackAudit,
                                //             valueField: 'value',
                                //             textField: 'text',
                                //             required: true
                                //         }
                                //     }
                                // },

                                //{
                                //    field: 'CanBackMethod', title: '是否反审判断方法', align: "center", editor: {
                                //        type: "validatebox",
                                //    }
                                //},
                                //         {
                                //             field: 'BackAuditMethod', title: '反审方法 ', align: "center", width: 100, editor: {
                                //                 type: "validatebox",
                                //                 options: {
                                //                 }
                                //             }
                                //         },
                                //             {
                                //                 field: 'CanReSubmit', title: '驳回后初始化 ', align: "center", width: 100, formatter: function (value, row, index) {
                                //                     return com.getArrayText(StaticCombo.CanBackAudit, value);
                                //                 }, editor: {
                                //                     type: "combobox",
                                //                     options: {
                                //                         data: StaticCombo.CanBackAudit,
                                //                         valueField: 'value',
                                //                         textField: 'text',
                                //                         required: true
                                //                     }
                                //                 }
                                //             },
                                //         {
                                //             field: 'ReSubmitMethod', title: '初始化方法 ', align: "center", width: 100, editor: {
                                //                 type: "validatebox",
                                //                 options: {
                                //                 }
                                //             }
                                //         },

             //{
             //    field: 'RejectToAdd', title: '驳回通知制单人 ', align: "center", width: 100,
             //    formatter: function (value, row, index) {
             //        return com.getArrayText(StaticCombo.informMaker, value);
             //    }, editor: {
             //        type: "combobox",
             //        options: {
             //            data: StaticCombo.informMaker,
             //            valueField: 'value',
             //            textField: 'text',
             //            required: true
             //        }
             //    }
             //},
             //{
             //    field: 'PassToAdd', title: '通过通知制单人 ', align: "center", width: 100,
             //    formatter: function (value, row, index) {
             //        return com.getArrayText(StaticCombo.informMaker, value);
             //    }, editor: {
             //        type: "combobox",
             //        options: {
             //            data: StaticCombo.informMaker,
             //            valueField: 'value',
             //            textField: 'text',
             //            required: true
             //        }
             //    }
             //},
             //{
             //    field: 'ShowFile', title: '显示附件 ', align: "center", width: 100,
             //    formatter: function (value, row, index) {
             //        return com.getArrayText(StaticCombo.informMaker, value);
             //    }, editor: {
             //        type: "combobox",
             //        options: {
             //            data: StaticCombo.informMaker,
             //            valueField: 'value',
             //            textField: 'text',
             //            required: true
             //        }
             //    }
             //},

             { field: 'FillDate', title: '填写日期 ', align: "center", width: 100 },
             { field: 'ManClerk', title: '维护人 ', align: "center", width: 100 },
           {
               field: 'Note', title: '备注 ', align: "center", width: 150, editor: {
                   type: "validatebox",
                   options: {

                   }
               }
           }]], onAfterEdit: function (rowIndex, rowData, changes) {
               if (editAction == "add") {
                   com.ajax({
                       url: "/Review/AddReviewType",
                       data: rowData,
                       success: function (data) {
                           com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                       }
                   });
               }
               if (editAction == "edit") {
                   com.ajax({
                       url: "/Review/EditReviewType",
                       data: rowData,
                       success: function (data) {
                           com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                       }
                   });
               }
               editRow = undefined;
           }, onCancelEdit: function (rowIndex, rowData) {
               $("#tbList").datagrid("rejectChanges");

           }
        });
    });
</script>

<script type="text/javascript">

    editRow = undefined;
    editAction = undefined;
    function funcSearch() {
        var para = com.serializeSearchArray("form1");
        $("#tbList").datagrid("load", para);

    }
    function funcAdd() {
        //添加时先判断是否有开启编辑的行，如果有则把开户编辑的那行结束编辑
        if (editRow != undefined) {

        }
        //添加时如果没有正在编辑的行，则在datagrid的第一行插入一行
        if (editRow == undefined) {
            $("#tbList").datagrid("insertRow", {
                index: 0, // index start with 0
                row: {

                }
            });
            //将新插入的那一行开户编辑状态
            $("#tbList").datagrid("beginEdit", 0);
            //给当前编辑的行赋值
            editRow = 0;
            editAction = "add";
        }
    }
    function funcEdit() {
        var row = $('#tbList').datagrid('getSelected');
        if (row) {
            if (editRow != undefined) {
            }
            else {
                var index = $("#tbList").datagrid('getRowIndex', row);
                //   var index = row.Id;
                $("#tbList").datagrid('beginEdit', index);
                editAction = "edit";
                editRow = index;
            }
        }
        else {
            com.message("information", "请选中一行");
        }
    }
    function funcSave() {
        $('#tbList').datagrid('endEdit', editRow);
    }
    function funcCancel() {
        $('#tbList').datagrid("cancelEdit", editRow);
        editRow = undefined;
        editAction = undefined;
    }
    function funcReload() {
        $("#form1").form("reset");
        var para = com.serializeSearchArray("form1");
        $("#tbList").datagrid("load", para);
    }

</script>
<div id="divTotal" style="height: 100%; width: 100%">
    <div id="master" class="container_12" style="height: auto">
        <form id="form1">
            所属模块:
            <input id="ModName" name="ModName" data-cp="=" class="easyui-combobox" data-options="valueField:'value',textField:'text',data:StaticCombo.ModName,panelHeight:'auto',editable:false" />
            <input id="DocName" name="DocName" data-cp="co" class="easyui-textbox" data-options="prompt:'审批类型'" />
        </form>
    </div>
    <table id="tbList" title="审批类型表 " style="width: 100%"></table>
</div>
